package com.xunlai.infra.permission.business.controller;

import com.xunlai.infra.permission.business.service.RouteService;
import com.xunlai.infra.permission.business.vo.route.*;
import com.xunlai.infra.permission.common.vo.BasePageRespVo;
import com.xunlai.infra.permission.common.vo.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liang
 * @date 8/16/23 9:57 PM
 */
@RestController
@RequestMapping("travel/manage/route/subject")
public class RouteSubjectManageController {

    private RouteService routeService;

    @PostMapping("create")
    public BaseResponse<Long> createRouteSubject(@RequestBody RouteSubjectCreateVo routeSubjectCreateVo) {
        return BaseResponse.success(routeService.createRouteSubject(routeSubjectCreateVo));
    }

    @GetMapping("list")
    public BaseResponse<BasePageRespVo<RouteSubjectListVo>> listRouteSubject(RouteSubjectQueryVo routeSubjectQueryVo,
                                                                             @RequestParam(required = false,defaultValue = "1") Integer pageNum,
                                                                             @RequestParam(required = false,defaultValue = "10") Integer pageSize) {
        return BaseResponse.success(routeService.listRouteSubject(routeSubjectQueryVo,pageNum,pageSize));
    }

    @GetMapping("all")
    public BaseResponse<List<RouteSubjectListVo>> listAllRouteSubject(RouteSubjectQueryVo routeSubjectQueryVo) {
        return BaseResponse.success(routeService.listAllRouteSubject());
    }

    @PutMapping("update/{id}")
    public BaseResponse<Boolean> updateRouteSubject(@PathVariable Long id ,@RequestBody RouteSubjectCreateVo routeSubjectCreateVo){
        routeService.updateRouteSubject(id,routeSubjectCreateVo);
        return BaseResponse.success();
    }


    @Autowired
    public void setRouteService(RouteService routeService) {
        this.routeService = routeService;
    }
}
